package com.itheima.tlais_web_management.mapper;

import com.itheima.tlais_web_management.pojo.Emp;
import org.apache.ibatis.annotations.*;

import java.time.LocalDate;
import java.util.List;

@Mapper
public interface EmpMapper {

    /**
     * 查询数据总数
     * @return
     */
//    @Select("select count(*) from tlias.emp")
//    Long count();

    /**
     * 查询列表数据
     * @return
     */
//    @Select("select * from tlias.emp limit #{start},#{pageSize}")
//    List<Emp> page(@Param("start") Integer start,@Param("pageSize") Integer pageSize);

//    @Select("select * from tlias.emp")
    List<Emp> list(@Param("name") String name, @Param("gender") Short gender, @Param("begin") LocalDate begin, @Param("end") LocalDate end);


    void delete(@Param("ids") List<Integer> ids);

    @Insert("insert into tlias.emp(username, name, gender, image, job, entrydate, dept_id, create_time, update_time) VALUES " +
            "(#{username},#{name},#{gender},#{image},#{job},#{entrydate},#{deptId},#{createTime},#{updateTime})")
    void save(Emp emp);

    @Select("select * from tlias.emp where id = #{id}")
    Emp getbyid(@Param("id") Integer id);

    void update(Emp emp);

    @Select("select * from tlias.emp where username = #{username} and password = #{password}")
    Emp login(Emp emp);

    //根据部门 id 删除员工
    @Delete("delete from tlias.emp where dept_id = #{dept_id}")
    void deletebydeptid(Integer dept_id);

    @Select("select * from tlias.emp where job = #{id}")
    List<Emp> getbyjobid(@Param("id") Integer id);

    @Select("select id,name from tlias.emp where id = #{headTeacher}")
    Emp getById(@Param("headTeacher") Integer headTeacher);
}
